<template>
  <div class="content-box">
    <div v-if="hideTwo == 'first'">
    <nav-title title="基本信息" />
    <div class="line">
      <span class="important">*</span>
      <div class="label">姓</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.lastName">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">名</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.firstName">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">姓名拼音</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.nameAc">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">曾用名</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.rsUsedName">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">性别</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="sexVal" v-model="basicInfo.sex"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">国籍</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="couVal" v-model="basicInfo.country"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">出生日期</div>
      <div class="value">
        <group>
          <datetime :min-year="1900" :max-year="2100" value-text-align="left" placeholder="请选择" v-model="basicInfo.birthdate"></datetime>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">民族</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="natVal" v-model="basicInfo.ethnicGrpCd"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">籍贯</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.nativePlaceChn">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">最高学历</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="heduVal" v-model="basicInfo.highestEducLvl"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">毕业学校</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.cSchool">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">专业</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.cMajor">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">参加工作时间</div>
      <div class="value">
        <group>
          <datetime :min-year="1900" :max-year="2100" value-text-align="left" placeholder="请选择" v-model="basicInfo.startDtChn"></datetime>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">入本公司时间</div>
      <div class="value">
        <group>
          <datetime :min-year="1900" :max-year="2100" value-text-align="left" placeholder="请选择" v-model="basicInfo.rsWklifBgnDt"></datetime>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">现在职称</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.cPosition">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">政治面貌</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="polsVal" v-model="basicInfo.politicalStaChn"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">入党(团)时间</div>
      <div class="value">
        <group>
          <datetime :min-year="1900" :max-year="2100" value-text-align="left" placeholder="请选择" v-model="basicInfo.cDate"></datetime>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">有无驾照</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="lcList" v-model="basicInfo.cYesNo"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">身高(CM)</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.rsPersHeight">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">体重(KG)</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.rsPersWeight">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">血型</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="blodVal" v-model="basicInfo.rsBloodType"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">健康状况</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="helVal" v-model="basicInfo.rsHealthStatus"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">婚姻状况</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="mryVal" v-model="basicInfo.marStatus"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">生育状况</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="bearVal" v-model="basicInfo.cBear"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">证件类型</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="itVal" v-model="basicInfo.nationalIdType"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">证件号码</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.nationalId">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">户籍地址</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.addresslong1">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">家庭详细地址</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.addresslong3">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">现在居住地址</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.addresslong2">
      </div>
    </div>
    <div class="line" style="border-bottom:0;">
      <span class="important">*</span>
      <div class="label">指定送达地址</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" @on-hide="setAddr(basicInfo.cSendType)" :options="sendVal" v-model="basicInfo.cSendType"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label"></div>
      <div class="value">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cAddress">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">住宅电话</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.phone1">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">手机号码</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.phone">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">个人Email</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.emailAddr">
      </div>
    </div>
    <!-- <div class="line">
      <span class="important"></span>
      <div class="label">个人档案所在地</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.cArchiveAddr">
      </div>
    </div> -->
    </div>

    <div v-if="hideTwo == 'second'">
    <nav-title title="个人特长及兴趣爱好" />
    <div class="line">
      <span class="important"></span>
      <div class="label">个人特长</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.cDescrlong">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">兴趣爱好</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.rsHobby">
      </div>
    </div>
    </div>

    <div v-if="hideTwo == 'third'">
    <nav-title title="其他需要说明的情况" />
    <div class="line" style="border-bottom:0;">
      <span class="important"></span>
      <div class="label">是否有过犯罪记录？</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="lcList" v-model="basicInfo.cYesNo4"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label"></div>
      <div class="value">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cDescrlong1">
      </div>
    </div>

    <div class="line" style="border-bottom:0;">
      <span class="important"></span>
      <div class="label">曾否因大病入院或患有特殊疾病？</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="lcList" v-model="basicInfo.cYesNo1"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label"></div>
      <div class="value">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cDescrlong2">
      </div>
    </div>

    <div class="line" style="border-bottom:0;">
      <span class="important"></span>
      <div class="label">是否对其他公司负竞业限制义务？</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="lcList" v-model="basicInfo.cYesNo2"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label"></div>
      <div class="value">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cDescrlong3">
      </div>
    </div>

    <div class="line" style="border-bottom:0;">
      <span class="important"></span>
      <div class="label">是否曾在本集团任职或建立过劳动关系？</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" :options="lcList" v-model="basicInfo.cYesNo3"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label"></div>
      <div class="value">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cDescrlong4">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">其他补充说明</div>
      <div class="value">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cDescrlong5">
      </div>
    </div>
  </div>
    <div class="bsbtn" @click="save">
      保存
    </div>
  </div>

</template>

<script>
import { Datetime, Group ,PopupRadio } from 'vux'
import { getDicItem, saveBsinfo, getCountry, getNation, getIdType, getQrmsg } from '../../../../api/api'
import { json2Form } from '../../../../util/http'

export default {

  name: 'input-information',
  components: {
    Datetime, Group , PopupRadio
  },
  mounted(){
    if(this.$store.state.hid){
      this.basicInfo.rsHireId = this.$store.state.hid
    }
    this.getsexDic()
    this.getcoulb()
    this.getnatlb()
    this.gethlDic()
    this.getpolDic()
    this.getbloodDic()
    this.gethelDic()
    this.getmarDic()
    this.getbearDic()
    this.getIdlb()
    this.getsendDic()
  },
  data() {
    return {
      basicInfo:{
        name:'',
        rsHireId: '',
        country:''
      },
      getDate:'',
      score:'',
      sexVal:[],
      couVal:[],
      natVal:[],
      heduVal:[],
      polsVal:[],
      blodVal:[],
      helVal:[],
      mryVal:[],
      bearVal:[],
      itVal:[],
      sendVal:[],
      hideTwo:'',
      lcList: [{value: '有', key: 'Y'},{value: '无', key: 'N'}],
    }
  },
  created() {
    this.getBsif()
  },
  methods: {
    setAddr(item) {
      if(item == 100){
        this.basicInfo.cAddress = this.basicInfo.addresslong1
      }
      if(item == 110){
        this.basicInfo.cAddress = this.basicInfo.addresslong3
      }
      if(item == 120){
        this.basicInfo.cAddress = this.basicInfo.addresslong2
      }
    },
    save() {
      var that = this
      that.basicInfo.name = this.basicInfo.lastName+this.basicInfo.firstName
      console.log(this.basicInfo)
      if(that.basicInfo.firstName == undefined || that.basicInfo.firstName == ''){
        this.$vux.alert.show({
          title: '警告',
          content: '请输入您的名字'
        });
        return;
      }
      if(that.basicInfo.lastName == undefined || that.basicInfo.lastName == ''){
        this.$vux.alert.show({
          title: '警告',
          content: '请输入您的姓氏'
        });
        return;
      }
      if(that.basicInfo.nameAc == '' || that.basicInfo.nameAc == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请输入姓名拼音'
        });
        return;
      }
      if(that.basicInfo.sex == '' || that.basicInfo.sex == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请选择您的性别'
        });
        return;
      }
      if(that.basicInfo.birthdate == ''){
        this.$vux.alert.show({
          title: '警告',
          content: '请选择出生日期'
        });
        return;
      }
      if(that.basicInfo.ethnicGrpCd == ''|| that.basicInfo.ethnicGrpCd == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请选择民族'
        });
        return;
      }
      if(that.basicInfo.nativePlaceChn == '' || that.basicInfo.nativePlaceChn == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请输入您的籍贯'
        });
        return;
      }
      if(that.basicInfo.startDtChn == ''){
        this.$vux.alert.show({
          title: '警告',
          content: '请选择参加工作时间'
        });
        return;
      }
      if(that.basicInfo.politicalStaChn == ''||that.basicInfo.politicalStaChn == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请选择政治面貌'
        });
        return;
      }
      if(that.basicInfo.rsHealthStatus == ''||that.basicInfo.rsHealthStatus == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请选择健康状况'
        });
        return;
      }
      if(that.basicInfo.marStatus == ''||that.basicInfo.marStatus == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请选择婚姻状况'
        });
        return;
      }
      if(that.basicInfo.cBear == ''||that.basicInfo.cBear == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请选择生育状况'
        });
        return;
      }
      if(that.basicInfo.nationalIdType == ''||that.basicInfo.nationalIdType == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请选择证件类型'
        });
        return;
      }
      if(that.basicInfo.nationalId == '' || that.basicInfo.nationalId == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请输入证件号码'
        });
        return;
      }
      if(that.basicInfo.addresslong1 == '' || that.basicInfo.addresslong1 == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请输入户籍地'
        });
        return;
      }
      if(that.basicInfo.addresslong2 == '' || that.basicInfo.addresslong2 == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请输入现居地'
        });
        return;
      }
      if(that.basicInfo.cSendType == ''){
        this.$vux.alert.show({
          title: '警告',
          content: '请选择送达方式'
        });
        return;
      }
      if(that.basicInfo.cAddress == '' || that.basicInfo.cAddress == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请输入送达地址'
        });
        return;
      }
      if(that.basicInfo.phone == '' || that.basicInfo.phone == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请输入手机号码'
        });
        return;
      }
      if(that.basicInfo.emailAddr == '' || that.basicInfo.emailAddr == undefined){
        this.$vux.alert.show({
          title: '警告',
          content: '请输入个人Email'
        });
        return;
      }
      console.log(that.basicInfo)
      saveBsinfo(json2Form(that.basicInfo)).then(res => {
        if(res && res.retCode === '000000' ){
          //保存成功
          this.$vux.alert.show({
            title: '提示',
            content: '保存成功',
            onHide () {
              that.$router.push('/informationCollection/userInfo');
            }
          })

        }else{
          // 显示
          this.$vux.alert.show({
            title: '',
            content: res.retMsg
          })
        }
      }).catch (res=>{
        this.$vux.alert.show({
          title: '警告',
          content: '网络异常，请稍后重试'
        })
      })
    },

    //性别
    getsexDic() {
      this.sexVal = []
      let params = {
        fileName: 'SEX'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.sexVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
      }).catch(res => {

      })
    },
    //国籍
    getcoulb() {
      getCountry().then(res => {
        res.retData.forEach((val) => {
          if (val.country == 'CHN') this.basicInfo.country = val.country;
          this.couVal.push({value: val.descrshort, key: val.country})
        });
      })
    },
    //民族
    getnatlb() {
      getNation().then(res => {
        res.retData.forEach((val) => {
          this.natVal.push({value: val.descrshort, key: val.ethnicGrpCd})
        });
      })
    },
    //学历
    gethlDic() {
      this.labelVal = []
      let params = {
        fileName: 'HIGHEST_EDUC_LVL'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.heduVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
      }).catch(res => {

      })
    },
    //政治
    getpolDic() {
      let params = {
        fileName: 'POLITICAL_STA_CHN'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.polsVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
      }).catch(res => {

      })
    },
    //血型
    getbloodDic() {
      let params = {
        fileName: 'RS_BLOOD_TYPE'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.blodVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
      }).catch(res => {

      })
    },
    //健康
    gethelDic() {
      let params = {
        fileName: 'RS_HEALTH_STATUS'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.helVal.push({value: val.xlatshortname, key: val.fieldvalue})
        })
      }).catch(res => {

      })
    },
    //婚姻
    getmarDic() {
      let params = {
        fileName: 'MAR_STATUS'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.mryVal.push({value: val.xlatshortname, key: val.fieldvalue})
        })
      }).catch(res => {

      })
    },

    //生育
    getbearDic() {
      let params = {
        fileName: 'C_BEAR'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.bearVal.push({value: val.xlatshortname, key: val.fieldvalue})
        })
      }).catch(res => {

      })
    },
    //证件
    getIdlb() {
      getIdType().then(res => {
        res.retData.forEach((val) => {
          this.itVal.push({value: val.descr.substring(3), key: val.nationalIdType})
        })
      })
    },
    //指定送达
    getsendDic() {
      let params = {
        fileName: 'C_SEND_TYPE'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.sendVal.push({value: val.xlatshortname, key: val.fieldvalue})
        })
      }).catch(res => {

      })
    },
    getBsif() {
      if(this.$route.params.bsifs){
        this.basicInfo = this.$route.params.bsifs
        this.hideTwo = this.$route.params.whc
      }
    }
  },
  watch: {
    '$route': 'getBsif'
  }
}
</script>
<style type="text/scss" lang="scss">
  @import "./editinfo";
</style>
